package com.data.JVM.chapter04;

import java.util.ArrayList;

/**
 * 内存占位符，一个对象大约64k
 *
 */
public class Test_Console {
    static class OOMObject{
        public byte[]  placeholder  = new byte[64*1024];
    }


    public static void fillHeap(int num) throws InterruptedException {
        ArrayList<OOMObject> list = new ArrayList<OOMObject>();
        for (int i=0;i<num;i++){
            Thread.sleep(50);
            list.add(new OOMObject());
        }
        System.gc();
    }

    public static void main(String[] args) throws InterruptedException {
        fillHeap(1000);
    }
}
